/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.engagesoft.cashflow.entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author rchajin
 */
@Entity
@Table(name = "tipo_documento")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TipoDocumento.findAll", query = "SELECT t FROM TipoDocumento t"),
    @NamedQuery(name = "TipoDocumento.findByIdTipoDocumento", query = "SELECT t FROM TipoDocumento t WHERE t.idTipoDocumento = :idTipoDocumento"),
    @NamedQuery(name = "TipoDocumento.findByNombreDoc", query = "SELECT t FROM TipoDocumento t WHERE t.nombreDoc = :nombreDoc"),
    @NamedQuery(name = "TipoDocumento.findByPrefijoDoc", query = "SELECT t FROM TipoDocumento t WHERE t.prefijoDoc = :prefijoDoc"),
    @NamedQuery(name = "TipoDocumento.findByConsecutivoTipoDoc", query = "SELECT t FROM TipoDocumento t WHERE t.consecutivoTipoDoc = :consecutivoTipoDoc"),
    @NamedQuery(name = "TipoDocumento.findByIndHabilitadotipod", query = "SELECT t FROM TipoDocumento t WHERE t.indHabilitadotipod = :indHabilitadotipod")})
public class TipoDocumento implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_tipo_documento")
    private Integer idTipoDocumento;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "nombre_doc")
    private String nombreDoc;
    @Size(max = 10)
    @Column(name = "prefijo_doc")
    private String prefijoDoc;
    @Column(name = "consecutivo_tipo_doc")
    private Integer consecutivoTipoDoc;
    @Basic(optional = false)
    @NotNull
    @Column(name = "indHabilitado_tipod")
    private boolean indHabilitadotipod;
    @JoinColumn(name = "id_sucursal", referencedColumnName = "id_sucursal")
    @ManyToOne
    private Sucursal idSucursal;
    @JoinColumn(name = "id_concepto_tipo_doc", referencedColumnName = "id_concepto_tipo_doc")
    @ManyToOne
    private ConceptoTipoDoc idConceptoTipoDoc;
    @OneToMany(mappedBy = "idTipoDocumento")
    private Collection<Documento> documentoCollection;

    public TipoDocumento() {
    }

    public TipoDocumento(Integer idTipoDocumento) {
        this.idTipoDocumento = idTipoDocumento;
    }

    public TipoDocumento(Integer idTipoDocumento, String nombreDoc, boolean indHabilitadotipod) {
        this.idTipoDocumento = idTipoDocumento;
        this.nombreDoc = nombreDoc;
        this.indHabilitadotipod = indHabilitadotipod;
    }

    public Integer getIdTipoDocumento() {
        return idTipoDocumento;
    }

    public void setIdTipoDocumento(Integer idTipoDocumento) {
        this.idTipoDocumento = idTipoDocumento;
    }

    public String getNombreDoc() {
        return nombreDoc;
    }

    public void setNombreDoc(String nombreDoc) {
        this.nombreDoc = nombreDoc;
    }

    public String getPrefijoDoc() {
        return prefijoDoc;
    }

    public void setPrefijoDoc(String prefijoDoc) {
        this.prefijoDoc = prefijoDoc;
    }

    public Integer getConsecutivoTipoDoc() {
        return consecutivoTipoDoc;
    }

    public void setConsecutivoTipoDoc(Integer consecutivoTipoDoc) {
        this.consecutivoTipoDoc = consecutivoTipoDoc;
    }

    public boolean getIndHabilitadotipod() {
        return indHabilitadotipod;
    }

    public void setIndHabilitadotipod(boolean indHabilitadotipod) {
        this.indHabilitadotipod = indHabilitadotipod;
    }

    public Sucursal getIdSucursal() {
        return idSucursal;
    }

    public void setIdSucursal(Sucursal idSucursal) {
        this.idSucursal = idSucursal;
    }

    public ConceptoTipoDoc getIdConceptoTipoDoc() {
        return idConceptoTipoDoc;
    }

    public void setIdConceptoTipoDoc(ConceptoTipoDoc idConceptoTipoDoc) {
        this.idConceptoTipoDoc = idConceptoTipoDoc;
    }

    @XmlTransient
    public Collection<Documento> getDocumentoCollection() {
        return documentoCollection;
    }

    public void setDocumentoCollection(Collection<Documento> documentoCollection) {
        this.documentoCollection = documentoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTipoDocumento != null ? idTipoDocumento.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TipoDocumento)) {
            return false;
        }
        TipoDocumento other = (TipoDocumento) object;
        if ((this.idTipoDocumento == null && other.idTipoDocumento != null) || (this.idTipoDocumento != null && !this.idTipoDocumento.equals(other.idTipoDocumento))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.engagesoft.cashflow.entidades.TipoDocumento[ idTipoDocumento=" + idTipoDocumento + " ]";
    }
    
}
